require(["common", "jQuery", "coAjax", "queryString", "hash_routie"], function(jSouper, $, coAjax, QueryString, hash_routie) {
	hash_routie.on("info", function() {
		var queryString = new QueryString(location.hash);
		var _type = queryString.get("type");
		if (_type == '2') {
			App.set('title', '修改密码');
			App.set('infotype', 'pwd');
		} else {
			App.set('title', '基本信息');
			App.set('infotype', '');
		};
	})
	//完成编辑，提交表单
	App.set("$Event.admin.post_edit", function(e) {
		var info = App.get("bus_loginer.info");
		coAjax.put(appConfig.bus.set_info_url, App.get("bus_loginer.info"), function(result) {
			// console.log(result);
			App.set("bus_loginer", result.result);
			alert('success', '修改信息成功！');
			App.set("$Cache.admininfo.is_edit", false);
		}, function(errorCode, xhr, errorMsg) {
			switch (errorCode) {
				case "00025":
					alert("error", "登录超时");
					href.toLogin();
					break;
				case "00041":
					alert("error", "请检查您的身份证格式");
					break;
				case "00043":
					alert("error", "请检查您的邮箱格式");
					break;
				case "00044":
					alert("error", "请检查您的手机号码");
					break;
				default:
					alert("error", errorMsg);
			}
		});
	});
	App.set("$Event.bus.changepwd.change", function(e, vm) {
		var current_pwd = App.get("$Cache.bus.changepwd.current_pwd");
		var new_pwd = App.get("$Cache.bus.changepwd.new_pwd");
		var new_pwd_bak = App.get("$Cache.bus.changepwd.new_pwd_bak");
		if (!current_pwd) {
			alert("warn", "请输入当前密码");
			return;
		}
		if (new_pwd !== new_pwd_bak) {
			alert("warn", "两次密码不匹配");
			return;
		}
		coAjax.put(appConfig.bus.change_password, {
			old_password: current_pwd,
			new_password: new_pwd
		}, function(result) {
			App.set("$Cache.bus.changepwd.current_pwd", "");
			App.set("$Cache.bus.changepwd.new_pwd", "");
			App.set("$Cache.bus.changepwd.new_pwd_bak", "");
			alert("success", "密码修改成功");
		}, function(errorCode, xhr, errorMsg) {
			alert("error", errorMsg);
		});
	})
})